$.wajax({
    type: "POST",
    url: CONTEXT_PATH + '/game/game/queryAll',
    success: function(result) {
    	$("#gameId").select2({
    		  placeholder : "请选择游戏",
    		  data: result.data,
    		  width: '100px'
    	});
    	
    	if (result.data != null && result.data.length > 0) {
    		$('#gameId').val(result.data[0].id).trigger("change");
    	}
    }
});

function changeAll(){
	var sall = document.getElementById("sall");//获取标题栏中的操作对象
	var seach = document.getElementsByName("channelIds");//获取内容栏的对象
	for(var i = 0; i < seach.length; i++) {
		if (sall.checked) {
			seach[i].checked = true;
		} else{
			seach[i].checked = false;
		}
	}
}

$('#print_list_btn_submit').click(function () {
    $("#print_list_form").submit();
});

$("#print_list_form").validate({
    rules: {
    	gameId: {
            required: true
        },
        channelIds: {
            required: true
        }
    },
    messages: {
    	gameId: "游戏是必填项",
    	channelIds: "请选择渠道"
    },
    errorElement: "span",
    submitHandler: function(form) {
        var url = CONTEXT_PATH+'/game/game_process/getPrintList';
        $.wajax({
            type: "POST",
            url: url,
            data: $(form).serialize(),
            success: function(result) {
            	window.parent.showLayer(result.data);
                //$(form)[0].reset();
            }
        });
    }
});//End
